package com.ls.day14;

/**
 * @author ：xxx
 * @description：TODO
 * @date ：2021/3/30 22:40
 */
public class SearchInsert {
    public int searchInsert(int[] nums, int target) {
        int l=0,r=nums.length-1,mid=0;
        while (l<=r){
            mid = (l+r)/2;
            if (nums[mid]<target) l=mid+1;
            else if(nums[mid]==target)return mid;
            else r=mid-1;
        }
        return l;
    }
}
